const { Sequelize } = require('sequelize')
const initModules = require('../models/init-models')
//  连接数据库，数据库，用户名，密码
const sequelize = new Sequelize('xdclass','root','root',{
  host:'182.92.122.236',
  dialect: 'mysql', // 数据库类型
  timezone: '+08:00'
});

(async function () {
  try {
  await sequelize.authenticate();
  console.log('数据库链接成功');
  } catch (error) {
  console.error('数据库链接失败:', error);
  }
 })()

 const modules = initModules(sequelize)
 module.exports = {...modules, sequelize }